package org.misty.seckill.controller;

import org.misty.seckill.redis.RedisService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@Deprecated
@RestController
@RequestMapping("/redis")
public class RedisController {
  @Autowired
  private RedisService redisService;

  @RequestMapping("/set/{key}/{value}")
  public boolean setKey(@PathVariable("key") String key, @PathVariable("value") String value) {
    return redisService.set(key, value);
  }

  @GetMapping("/{key}")
  public String getKey(@PathVariable("key") String key) {
    return redisService.get(key, String.class);
  }
}
